﻿using AtentoFramework2008.Infrastructure.Persistence;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NStore.Domain;
using NStore.Infrastructure.Repositories;

namespace NStore.Infrastructure.Tests.Repositories
{
    [TestClass]
    public class UserRepositoryTest
    {
        [TestMethod]
        public void GetByUserName_WithUserPersisted_ShouldReturnUserRight()
        {
            User user = new User("username","password");
            UserRepository repository = new UserRepository();
            
            repository.Add(user);
            NHibernateSessionManager.Instance.CloseSession(true);

            User userRecovered = repository.GetByUserName("username");
            Assert.IsNotNull(userRecovered);
            repository.Remove(userRecovered);
            
            NHibernateSessionManager.Instance.CloseSession(true);
        }
    }
}
